<template>
  <div class="shop-info">
    <div class="shop-top">
      <img v-lazy="shop.logo" alt="logo" />
      <span class="title">
        {{ shop.name }}
      </span>
    </div>
    <div class="shop-middle">
      <div class="shop-middle-item shop-middle-left">
        <div class="info-sells">
          <div class="sells-text">总销量</div>
          <div class="sells-count">{{ shop.sells | sellCountFilter }}</div>
        </div>
        <div class="info-goods">
          <div class="goods-text">全部宝贝</div>
          <div class="goods-count">
            {{ shop.goodsCount }}
          </div>
        </div>
      </div>
      <div class="shop-middle-item shop-middle-right">
        <table>
          <tr v-for="(item, index) in shop.score" :key="index">
            <td>{{ item.name }}</td>
            <td class="score" :class="{ 'score-better': item.isBetter }">
              <span>{{ item.score }}</span>
            </td>
            <td class="better" :class="{ 'better-more': item.isBetter }">
              <span>{{ item.isBetter ? "高" : "低" }}</span>
            </td>
          </tr>
        </table>
      </div>
    </div>

    <div class="shop-bottom">
      <span class="enter-shop">进店逛逛</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "DetailShopInfo",
  props: {
    shop: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {};
  },
  filters: {
    sellCountFilter(value) {
      if (value < 10000) return value;
      return (value / 10000).toFixed(2) + "万";
    },
  },
  mounted() {},

  methods: {},
};
</script>

<style lang="less" scoped>
.shop-info {
  padding: 25px 8px;
  border-bottom: 5px solid #f2f5f8;
  & > div {
    margin-top: 15px;
  }
}
.shop-top {
  line-height: 45px;
  img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid var(--color-tint);
  }
  .title {
    margin-left: 10px;
  }
  // /* 让元素垂直中心对齐 */
  // display: flex;
  // align-items: center;
}
.shop-middle {
  display: flex;
  align-items: center;
  .shop-middle-item {
    flex: 1;
  }
  .shop-middle-left {
    display: flex;
    justify-content: space-evenly;
    color: #333;
    text-align: center;
    border-right: 1px solid rgba(0, 0, 0);

    .sells-count,
    .goods-count {
      margin-top: 10px;
      font-weight: bold;
      font-size: 18px;
      color: var(--color-tint);
    }

    .sells-text,
    .goods-text {
      font-size: 12px;
    }
  }

  .shop-middle-right {
    font-size: 13px;

    table {
      width: 80%;
      margin: 0 30px;
      tr {
      }
      td {
        padding: 5px;
      }
    }

    .score {
      color: #5ea732;
      font-weight: bold;
    }

    .score-better {
      color: #f13e3a;
    }

    .better span {
      background-color: #5ea732;
      color: #fff;
    }

    .better-more span {
      background-color: #f13e3a;
    }
  }
}
.shop-bottom {
  text-align: center;
}
</style>
